from python_part.main_policy_database_member.ReadWriteClass import ReadWriteClass
import random

def generate_test_database():
    entity_path_to_rwclass_id: dict[str, int] = {
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/test_read_file": 11,
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/test_read_file2": 12,
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/object_change_test": 13,

        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/test_file1.txt": 1,
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/test_file2.txt": 2,
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/test_file3.txt": 3,
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/test_file4.txt": 4,
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing": 5,

    }
    rwclass_id_to_rwclass: dict[int, ReadWriteClass] = {
        11:ReadWriteClass(
            class_id=11,
            owner_class_id=11,
            class_ids_can_read_this={1},
            class_ids_can_write_this={1},
        ),
        12: ReadWriteClass(
            class_id=12,
            owner_class_id=12,
            class_ids_can_read_this={12},
            class_ids_can_write_this={12},
        ),
        13: ReadWriteClass(
            class_id=12,
            owner_class_id=12,
            class_ids_can_read_this={12},
            class_ids_can_write_this={12},
        ),
        1: ReadWriteClass(
            class_id=1,
            owner_class_id=12,
            class_ids_can_read_this={11, 12, 3, 4},
            class_ids_can_write_this={1},
        ),
        2: ReadWriteClass(
            class_id=2,
            owner_class_id=12,
            class_ids_can_read_this={12},
            class_ids_can_write_this={12},
        ),
        3: ReadWriteClass(
            class_id=3,
            owner_class_id=12,
            class_ids_can_read_this={2, 3, 4},
            class_ids_can_write_this={2, 3, 4},
        ),
        4: ReadWriteClass(
            class_id=4,
            owner_class_id=12,
            class_ids_can_read_this={2, 3, 4},
            class_ids_can_write_this={2, 3, 4},
        ),
        5: ReadWriteClass(
            class_id=5,
            owner_class_id=12,
            class_ids_can_read_this={2, 3, 4, 5},
            class_ids_can_write_this={2, 3, 4, 5},
        ),
    }
    global_config_dict: dict = {}
    return (entity_path_to_rwclass_id, rwclass_id_to_rwclass, global_config_dict)

def generate_random_database():
    NUM_OF_RWCLASS = 1000
    entity_path_to_rwclass_id: dict[str, int] = {
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/test_read_file": 1,
        "/home/ubuntu/python_serves/eBPF_Access_Control/Black_box_Testing/test_file1.txt": 2,

    }
    rwclass_id_to_rwclass: dict[int, ReadWriteClass] = {}
    for i in range(NUM_OF_RWCLASS):
        rwclass_id_to_rwclass[i] = ReadWriteClass(
            class_id=i,
            owner_class_id= i if random.random() > 0.5 else random.randint(0, NUM_OF_RWCLASS - 1),
            class_ids_can_read_this={random.randint(0, NUM_OF_RWCLASS - 1)
                                     for i in range(random.randint(0, NUM_OF_RWCLASS - 1))},
            class_ids_can_write_this={random.randint(0, NUM_OF_RWCLASS - 1)
                                     for i in range(random.randint(0, NUM_OF_RWCLASS - 1))},
        )
    global_config_dict: dict = {}
    return (entity_path_to_rwclass_id, rwclass_id_to_rwclass, global_config_dict)